package com.vcms.utility.loader.storage.factory;

import com.vcms.entity.store.item.CashStoreItem;
import com.vcms.entity.store.item.DrinksStoreItem;
import com.vcms.exception.VMCSException;
import com.vcms.utility.Environment;
import com.vcms.utility.loader.storage.engine.StorageEngine;
import com.vcms.utility.loader.storage.factory.impl.FileStorageFactory;
import com.vcms.utility.loader.storage.factory.impl.XmlStorageFactory;

/**
 * @author robin.foe A0092657U
 * Abstract Factory pattern
 */

public abstract class StorageFactory {
	
	private static StorageFactory instance;
	protected StorageFactory(){/*ENSURE SINGLETON*/}
	
	public static StorageFactory getInstance(){
		if(StorageFactory.instance == null){
			if(Environment.isStorageModeFile())
				StorageFactory.instance = new FileStorageFactory();
			else if(Environment.isStorageModeXml())
				StorageFactory.instance = new XmlStorageFactory();
		}
		return instance;
	}
	
	abstract public StorageEngine<CashStoreItem> createCashStorageEngine() throws VMCSException;
	abstract public StorageEngine<DrinksStoreItem> createDrinkStorageEngine() throws VMCSException;
	
}
